#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main() {
    long n, k;
    cin >> n >> k;
    vector<long> nums(n);
    for (long i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    unordered_map<long, long> hash;
    for (auto i : nums) {
        hash[i]++;
    }
    priority_queue<pair<long, long>> q;
    for (auto i : hash) {
        q.push({i.second, i.first});
    }

    priority_queue<long> q1;

    for (long i = 0; i < k; ++i) {
        q1.push(-(q.top().second));
        q.pop();
    }

    while(!q1.empty())
    {
        cout<<-q1.top()<<endl;
        q1.pop();
    }
}
